package com.yunxi.service.dubboService.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.yunxi.model.order.OrderCustomerFeature;
import com.yunxi.order.pojo.OrderCustomerFeatureVO;
import com.yunxi.order.service.OrderCustomerDetailDubboService;
import com.yunxi.order.service.OrderCustomerFeatureDubboService;
import com.yunxi.service.localService.OrderCustomerFeatureService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * <p>
 * 零售订单明细 服务实现类
 * </p>
 *
 * @author
 * @since 2019-06-05
 */
/*@com.alibaba.dubbo.config.annotation.Service(version = "${demo.service.version}",
        application = "${dubbo.application.id}",
        protocol = "${dubbo.protocol.id}",
        registry = "${dubbo.registry.id}"
)*/
public class OrderCustomerFeatureDubboServiceImpl implements OrderCustomerFeatureDubboService {

   @Autowired
   @Qualifier(value = "orderCustomerFeatureServiceImpl")
   OrderCustomerFeatureService orderCustomerFeatureService;


   @Override
   public OrderCustomerFeatureVO getById(String id) throws InvocationTargetException, IllegalAccessException {
      OrderCustomerFeature orderCustomerFeature = orderCustomerFeatureService.getById(id);
      OrderCustomerFeatureVO orderCustomerFeatureVO = new OrderCustomerFeatureVO();
      BeanUtils.copyProperties(orderCustomerFeature, orderCustomerFeatureVO);
      return orderCustomerFeatureVO;
   }

   @Override
   public void saveOrUpdate(OrderCustomerFeatureVO orderCustomerFeatureVO) throws InvocationTargetException, IllegalAccessException {
      OrderCustomerFeature orderCustomerFeature = new OrderCustomerFeature();
      BeanUtils.copyProperties(orderCustomerFeatureVO, orderCustomerFeature);
      orderCustomerFeatureService.saveOrUpdate(orderCustomerFeature);
   }

   @Override
   public void removeById(String id) {
      orderCustomerFeatureService.removeById(id);
   }

   @Override
   public PageInfo<OrderCustomerFeatureVO> findPageByVO(OrderCustomerFeatureVO orderCustomerFeatureVO, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException {
      PageInfo<OrderCustomerFeatureVO> pageInfo = orderCustomerFeatureService.pageByVo(orderCustomerFeatureVO, pageNum, pageSize);
      return pageInfo;
   }

   @Override
   public void removeByListVo(List<OrderCustomerFeatureVO> orderCustomerFeatureVOList) throws IllegalAccessException, InvocationTargetException, InstantiationException {
      orderCustomerFeatureService.removeByListVo(orderCustomerFeatureVOList);
   }

   @Override
   public void save(OrderCustomerFeatureVO orderCustomerFeatureVO) {
      OrderCustomerFeature orderCustomerFeature = new OrderCustomerFeature();
      BeanUtils.copyProperties(orderCustomerFeatureVO,orderCustomerFeature);
      orderCustomerFeatureService.save(orderCustomerFeature);
   }

   @Override
   public void update(OrderCustomerFeatureVO orderCustomerFeatureVO) {
      OrderCustomerFeature orderCustomerFeature = new OrderCustomerFeature();
      BeanUtils.copyProperties(orderCustomerFeatureVO,orderCustomerFeature);
      QueryWrapper<OrderCustomerFeature> queryWrapper = new QueryWrapper<>();
      //queryWrapper.eq("ORDER_NO",orderCustomerFeatureVO.getOrderNo());
      queryWrapper.eq("ORDER_CUSTOMER_FEATURE_ID",orderCustomerFeatureVO.getOrderCustomerFeatureId());
      orderCustomerFeatureService.update(orderCustomerFeature,queryWrapper);
   }
}
